//
//  UPRepaymentCarouseCell.m
//  Uang Pasti
//
//  Created by 李永彬 on 2025/8/24.
//

#import "UPRepaymentCarouseCell.h"
@interface UPRepaymentCarouseCell ()

@property (nonatomic, strong) UIImageView *containerImageView;
@property (nonatomic, strong) UIImageView *arrowImageView;
@property (nonatomic, strong) UILabel *titleLabel;

@end

@implementation UPRepaymentCarouseCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self commonInitSubviews];
    }
    return self;
}

- (void)commonInitSubviews {
    [self.containerImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self);
    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(self);
        make.leading.equalTo(self).offset(10);
        make.trailing.equalTo(self.arrowImageView.mas_leading).offset(-5);
    }];
    
    [self.arrowImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.trailing.equalTo(self).offset(-20);
        make.width.height.mas_equalTo(18);
    }];
}

- (UIImageView *)containerImageView {
    if (!_containerImageView) {
        _containerImageView = [[UIImageView alloc] init];
        _containerImageView.contentMode = UIViewContentModeScaleAspectFill;
        _containerImageView.image = [UIImage imageNamed:@"repay_bg"];
        _containerImageView.userInteractionEnabled = YES;
        [self addSubview:_containerImageView];
    }
    return _containerImageView;
}

- (UIImageView *)arrowImageView {
    if (!_arrowImageView) {
        _arrowImageView = [[UIImageView alloc] init];
        _arrowImageView.contentMode = UIViewContentModeScaleAspectFit;
        _arrowImageView.image = [UIImage imageNamed:@"repay_arrow"];
        [self addSubview:_arrowImageView];
    }
    return _arrowImageView;
}

- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.font = [UIFont systemFontOfSize:11];
        _titleLabel.textColor = [UIColor colorWithHexString:@"#F2DC6F"];
        _titleLabel.textAlignment = NSTextAlignmentCenter;
        _titleLabel.numberOfLines = 0;
        [self addSubview:_titleLabel];
    }
    return _titleLabel;
}

- (void)setLeaderible:(LeaderibleModel *)leaderible {
    _leaderible = leaderible;
    self.titleLabel.text = leaderible.enneasome;
}


@end
